package silo.dungeonbuddy;

import java.util.Vector;

public class InputMessage
{
	private String mess;
	private Start game;
	
	public InputMessage(String eMess,Start eGame)
	{
		mess=eMess;
		game=eGame;
	}//constructor
	
	public Power readPower()
	{
		IntValue k = new IntValue(0);
		Power p = new Power();
		String temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setName(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setDescription(temp.replace("|", ","));
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setPowerType(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setKeywords(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setActionType(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setRange(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setTarget(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setAttribute(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		p.setEnemyAttribute(temp);
		k.setValue(k.getValue() + 1);
		temp="";
		while(mess.charAt(k.getValue())!=',')
		{
			temp=temp + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		p.setDamageDescription(temp.replace("|", ","));
		return p;
	}//readPower()
	
	public Unit getBoardUnit(IntValue k)
	{
		String x="";
		String y="";
		String name="";
		String spriteRef="";
		String sizeX="";
		String sizeY="";
		String visible="";
		String owner="";
		//private int squareIndex;
		String row="";
		String column="";
		String speed="";
		String movement="";
		String stealth="";
		String perception="";
		String initiative="";
		String dex="";
		String strength="";
		String constitution="";
		String intelligence="";
		String wisdom="";
		String charisma="";
		String AC="";
		String fortitude="";
		String reflex="";
		String will="";
		String magicWeapon="";
		String magicImplement="";
		String weaponProficiency="";
		String maxHp="";
		String hp="";
		String turn="";
		
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			x=x+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			y=y+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			name=name+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			spriteRef=spriteRef+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeX=sizeX+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeY=sizeY+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			visible=visible+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		//IP
		while(mess.charAt(k.getValue())!=',')
		{
			owner=owner + mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			row=row+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			column=column+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			speed=speed+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			movement=movement+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			stealth=stealth+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			perception=perception+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			initiative=initiative+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			dex=dex+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			strength=strength+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			constitution=constitution+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			intelligence=intelligence+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			wisdom=wisdom+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			charisma=charisma+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			AC=AC+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			fortitude=fortitude+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			reflex=reflex+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			will=will+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			magicWeapon=magicWeapon+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loopk.setValue(k.getValue() + 1);
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			magicImplement=magicImplement+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loopk.setValue(k.getValue() + 1);
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			weaponProficiency=weaponProficiency+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			maxHp=maxHp+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			hp=hp+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			turn=turn+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		Unit u = new Unit(name,game,spriteRef,owner,Integer.parseInt(row),Integer.parseInt(column),Integer.parseInt(sizeX),Integer.parseInt(sizeY),Integer.parseInt(maxHp));
		try
		{
			u.setStealth(Integer.parseInt(stealth));
			u.setPerception(Integer.parseInt(perception));
			u.setHp(Integer.parseInt(hp));
			u.setTurn(Integer.parseInt(turn));
			u.setInitiative(Integer.parseInt(initiative));
			u.setDex(Integer.parseInt(dex));
			u.setStrength(Integer.parseInt(strength));
			u.setConstitution(Integer.parseInt(constitution));
			u.setIntelligence(Integer.parseInt(intelligence));
			u.setWisdom(Integer.parseInt(wisdom));
			u.setCharisma(Integer.parseInt(charisma));
			u.setAC(Integer.parseInt(AC));
			u.setFortitude(Integer.parseInt(fortitude));
			u.setReflex(Integer.parseInt(reflex));
			u.setWill(Integer.parseInt(will));
			u.setMagicWeapon(Integer.parseInt(magicWeapon));
			u.setMagicImplement(Integer.parseInt(magicImplement));
			u.setWeaponProficiency(Integer.parseInt(weaponProficiency));
		}catch(Exception e)
		{
			
		}//catch e
		if(visible.equals("1"))
		{
			u.setVisible(true);
		}else//if(visible.equals("1"))
		{
			u.setVisible(false);
		}//else -- if(visible.equals("1"))
		return u;
	}//private Unit getBoardUnit()
	
	private Terrain getBoardTerrain(IntValue k)
	{
		
		//"2" + "," + x + "," + y + "," + name + "," + spriteRef + "," + sizeX + "," + sizeY + "," + height + "," + "<vis>" + "," + row + "," + column + "," + "<obs>" + ","
		String x="";
		String y="";
		String name="";
		String spriteRef="";
		String sizeX="";
		String sizeY="";
		String height="";
		String visible="";
		String owner="";
		//private int squareIndex;
		String row="";
		String column="";
		String obs="";
		
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			x=x+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			y=y+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			name=name+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			spriteRef=spriteRef+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeX=sizeX+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeY=sizeY+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			height=height+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			visible=visible+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			row=row+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			column=column+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			obs=obs+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		boolean obstruction = true;
		if(obs.equalsIgnoreCase("0"))
		{
			obstruction=false;
		}
		int he = 5;
		try
		{
			he = Integer.parseInt(height);
		}catch(Exception e)
		{
			he = 5;
		}
		try
		{
			Terrain t = new Terrain(name,game,spriteRef,"IP",Integer.parseInt(row),Integer.parseInt(column),Integer.parseInt(sizeX),Integer.parseInt(sizeY),he,obstruction);
			return t;
		}catch(Exception e)
		{
			Terrain t = new Terrain(name,game,spriteRef,"IP",1,1,1,1,he,obstruction);
			return t;
		}
	}//private Terrain getBoardTerrain()
	
	private Marker getBoardMarker(IntValue k)
	{
		String x="";
		String y="";
		String name="";
		String spriteRef="";
		String sizeX="";
		String sizeY="";
		String row="";
		String column="";
		String unit="";
		
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			x=x+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			y=y+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			name=name+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			spriteRef=spriteRef+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeX=sizeX+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeY=sizeY+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			row=row+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			column=column+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			unit=unit+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		//String eName, Start game,String ref, String IP, int eRow, int eCol, int eSizeX, int eSizeY
		try
		{
			Marker m = new Marker(name,game,spriteRef,"127.0.0.1",Integer.parseInt(row),Integer.parseInt(column),Integer.parseInt(sizeX),Integer.parseInt(sizeY));
			try
			{
				if(game.getUnitList().size()>0)
				{
					for(int i=0;i<game.getUnitList().size();i++)
					{
						Unit u = (Unit)game.getUnitList().get(i);
						if(u.getName().equals(unit))
						{
							m.setUnit(u);
							u.getMarkers().add(m);
							i=game.getUnitList().size();
						}//if(u.getName().equals(unit))
					}//next i
				}//if(game.getUnitList().size()>0)
			}catch(Exception e2)
			{
				
			}//catch e2
			return m;
		}catch(Exception e)
		{
			Marker m = new Marker(name,game,spriteRef,"127.0.0.1",1,1,1,1);
			return m;
		}
	}//private Marker getBoardMarker()
	
	private Object getBoardObject(IntValue k)
	{
		String x="";
		String y="";
		String name="";
		String spriteRef="";
		String sizeX="";
		String sizeY="";
		String vis="";
		String row="";
		String column="";
		
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			x=x+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			y=y+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			name=name+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			spriteRef=spriteRef+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeX=sizeX+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeY=sizeY+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			vis=vis+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			row=row+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			column=column+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		boolean visible = true;
		if(vis.equalsIgnoreCase("0"))
		{
			visible=false;
		}
		try
		{
			Object o = new Object(name,game,spriteRef,"127.0.0.1",Integer.parseInt(row),Integer.parseInt(column),Integer.parseInt(sizeX),Integer.parseInt(sizeY));
			o.setVisible(visible);
			return o;
		}catch(Exception e)
		{
			Object o = new Object(name,game,spriteRef,"127.0.0.1",1,1,1,1);
			o.setVisible(visible);
			return o;
		}
	}//private Object getBoardObject()
	
	private Effect getBoardEffect(IntValue k)
	{
		//"5" + "," + x + "," + y + "," + spriteRef + "," + sizeX + "," + sizeY + "," + "1" + "," + row + "," + column + ","
		String x="";
		String y="";
		String name="";
		String spriteRef="";
		String sizeX="";
		String sizeY="";
		String vis="";
		String row="";
		String column="";
		
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			x=x+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			y=y+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			name=name+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			spriteRef=spriteRef+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeX=sizeX+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			sizeY=sizeY+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			vis=vis+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			row=row+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		while(mess.charAt(k.getValue())!=',')
		{
			column=column+mess.charAt(k.getValue());
			k.setValue(k.getValue() + 1);
		}//loop
		k.setValue(k.getValue() + 1);
		boolean visible = true;
		if(vis.equalsIgnoreCase("0"))
		{
			visible=false;
		}
		try
		{
			Effect e = new Effect(name,game,spriteRef,"127.0.0.1",Integer.parseInt(row),Integer.parseInt(column),Integer.parseInt(sizeX),Integer.parseInt(sizeY));
			e.setVisible(visible);
			return e;
		}catch(Exception e2)
		{
			Effect e = new Effect(name,game,spriteRef,"127.0.0.1",1,1,1,1);
			e.setVisible(visible);
			return e;
		}
	}//private Effect getBoardEffect()
	
	//TODO: Set up the code to make the client work with terrain, effects, markers, and objects when loading and updating the map
	public void loadMap()
	{
		try
		{
			IntValue k = new IntValue(0);
			int num=0;
			String temp="";
			
			String height="";
			String width="";
			String back="";
			
			while(mess.charAt(k.getValue())!= ',')
			{
				back = back + mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			k.setValue(k.getValue() + 1);
			while(mess.charAt(k.getValue())!= ',')
			{
				height = height + mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			k.setValue(k.getValue() + 1);
			while(mess.charAt(k.getValue())!= ',')
			{
				width = width + mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			k.setValue(k.getValue() + 1);
			
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			game.setBoard(new Board(Integer.parseInt(height),Integer.parseInt(width),new Background("Background",back,game,0,0,Integer.parseInt(width),Integer.parseInt(width)),game.getUnitList(),game.getTerrainList()));
			int rows = game.getBoard().getHeight();
			int cols = game.getBoard().getWidth();
			int hdiv = game.getHeight()/game.getSquaresPerScreen();
			for(int i=0;i<rows;i++)
			{
				for(int j=0;j<cols;j++)
				{
					//Vector v = gameBoard.getSquareList();
					Vector v = (Vector)game.getBoard().getSquareList().get(i);
					v.add(new Square("Square "+j+","+i,game,j*hdiv,i*hdiv,false,i,j));
					//gameBoard.getSquareList()[j][i]=new Square("Square "+i+","+j,this,i*hdiv,j*hdiv,false,j,i);
				}//next j
			}//next i
			//TODO: fix this: game.getUnitList().clear();
			Vector units = new Vector();
			while(num>0)
			{
				Unit u = getBoardUnit(k);
				units.add(u);
				num=num-1;
			}//loop
			while(game.getUnitList().size()>0)
			{
				Unit un = (Unit)game.getUnitList().get(0);
				game.removeUnit(un);
			}//loop
			game.getUnitList().clear();
			for(int i=0;i<units.size();i++)
			{
				Unit un = (Unit)units.get(i);
				/*if(un.getTurn()==1)
				{
					game.setTurnUnit(un);
				}*/
				game.addUnit(un);
			}//next i
			
			//TERRAIN:
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector terrain = new Vector();
			while(num>0)
			{
				Terrain t = getBoardTerrain(k);
				terrain.add(t);
				num=num-1;
			}//loop
			while(game.getTerrainList().size()>0)
			{
				Terrain te = (Terrain)game.getTerrainList().get(0);
				game.removeTerrain(te);
			}//loop
			game.getTerrainList().clear();
			for(int i=0;i<terrain.size();i++)
			{
				Terrain te = (Terrain)terrain.get(i);
				game.addTerrain(te);
			}//next i
			
			//MARKERS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector markers = new Vector();
			while(num>0)
			{
				Marker m = getBoardMarker(k);
				markers.add(m);
				num=num-1;
			}//loop
			while(game.getMarkerList().size()>0)
			{
				Marker ma = (Marker)game.getMarkerList().get(0);
				game.removeMarker(ma);
			}//loop
			game.getMarkerList().clear();
			for(int i=0;i<markers.size();i++)
			{
				Marker ma = (Marker)markers.get(i);
				game.addMarker(ma);
			}//next i
			
			//OBJECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector objects = new Vector();
			while(num>0)
			{
				Object o = getBoardObject(k);
				objects.add(o);
				num=num-1;
			}//loop
			while(game.getObjectList().size()>0)
			{
				Object ob = (Object)game.getObjectList().get(0);
				game.removeObject(ob);
			}//loop
			game.getObjectList().clear();
			for(int i=0;i<objects.size();i++)
			{
				Object ob = (Object)objects.get(i);
				game.addObject(ob);
			}//next i
			
			//EFFECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector effects = new Vector();
			while(num>0)
			{
				Effect e = getBoardEffect(k);
				effects.add(e);
				num=num-1;
			}//loop
			while(game.getEffectList().size()>0)
			{
				Effect ef = (Effect)game.getEffectList().get(0);
				game.removeEffect(ef);
			}//loop
			game.getEffectList().clear();
			for(int i=0;i<effects.size();i++)
			{
				Effect ef = (Effect)effects.get(i);
				game.addEffect(ef);
			}//next i
			
		}catch(Exception e)
		{
			System.out.println("ERROR: CODE 10");
			System.out.println(e.getMessage().toString());
			System.out.println(e.getLocalizedMessage().toString());
		}
	}//loadMap
	
	public void buildMap()
	{
		try
		{
			IntValue k = new IntValue(0);
			int num=0;
			String temp="";
			String height="";
			String width="";
			String back="";
			
			while(mess.charAt(k.getValue())!= ',')
			{
				back = back + mess.charAt(k.getValue());
				k.setValue(k.getValue()+1);
			}//loop
			k.setValue(k.getValue()+1);
			while(mess.charAt(k.getValue())!= ',')
			{
				height = height + mess.charAt(k.getValue());
				k.setValue(k.getValue()+1);
			}//loop
			k.setValue(k.getValue()+1);
			while(mess.charAt(k.getValue())!= ',')
			{
				width = width + mess.charAt(k.getValue());
				k.setValue(k.getValue()+1);
			}//loop
			k.setValue(k.getValue()+1);
			
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue()+1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue()+1);
			game.setBoard(new Board(Integer.parseInt(height),Integer.parseInt(width),new Background("Background",back,game,0,0,Integer.parseInt(width),Integer.parseInt(width)),game.getUnitList(),game.getTerrainList()));
			int rows = game.getBoard().getHeight();
			int cols = game.getBoard().getWidth();
			int hdiv = game.getHeight()/game.getSquaresPerScreen();
			for(int i=0;i<rows;i++)
			{
				for(int j=0;j<cols;j++)
				{
					//Vector v = gameBoard.getSquareList();
					Vector v = (Vector)game.getBoard().getSquareList().get(i);
					v.add(new Square("Square "+j+","+i,game,j*hdiv,i*hdiv,false,i,j));
					//gameBoard.getSquareList()[j][i]=new Square("Square "+i+","+j,this,i*hdiv,j*hdiv,false,j,i);
				}//next j
			}//next i
			//TODO: fix this: game.getUnitList().clear();
			Vector units = new Vector();
			while(num>0)
			{
				Unit u = getBoardUnit(k);
				units.add(u);
				num=num-1;
			}//loop
			while(game.getUnitList().size()>0)
			{
				Unit un = (Unit)game.getUnitList().get(0);
				game.removeUnit(un);
			}//loop
			game.getUnitList().clear();
			for(int i=0;i<units.size();i++)
			{
				Unit un = (Unit)units.get(i);
				/*if(un.getTurn()==1)
				{
					game.setTurnUnit(un);
				}*/
				game.addUnit(un);
			}//next i
			
			//TERRAIN:
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector terrain = new Vector();
			while(num>0)
			{
				Terrain t = getBoardTerrain(k);
				terrain.add(t);
				num=num-1;
			}//loop
			while(game.getTerrainList().size()>0)
			{
				Terrain te = (Terrain)game.getTerrainList().get(0);
				game.removeTerrain(te);
			}//loop
			game.getTerrainList().clear();
			for(int i=0;i<terrain.size();i++)
			{
				Terrain te = (Terrain)terrain.get(i);
				game.addTerrain(te);
			}//next i
			
			//MARKERS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector markers = new Vector();
			while(num>0)
			{
				Marker m = getBoardMarker(k);
				markers.add(m);
				num=num-1;
			}//loop
			while(game.getMarkerList().size()>0)
			{
				Marker ma = (Marker)game.getMarkerList().get(0);
				game.removeMarker(ma);
			}//loop
			game.getMarkerList().clear();
			for(int i=0;i<markers.size();i++)
			{
				Marker ma = (Marker)markers.get(i);
				game.addMarker(ma);
			}//next i
			
			//OBJECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector objects = new Vector();
			while(num>0)
			{
				Object o = getBoardObject(k);
				objects.add(o);
				num=num-1;
			}//loop
			while(game.getObjectList().size()>0)
			{
				Object ob = (Object)game.getObjectList().get(0);
				game.removeObject(ob);
			}//loop
			game.getObjectList().clear();
			for(int i=0;i<objects.size();i++)
			{
				Object ob = (Object)objects.get(i);
				game.addObject(ob);
			}//next i
			
			//EFFECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			k.setValue(k.getValue() + 1);
			Vector effects = new Vector();
			while(num>0)
			{
				Effect e = getBoardEffect(k);
				effects.add(e);
				num=num-1;
			}//loop
			while(game.getEffectList().size()>0)
			{
				Effect ef = (Effect)game.getEffectList().get(0);
				game.removeEffect(ef);
			}//loop
			game.getEffectList().clear();
			for(int i=0;i<effects.size();i++)
			{
				Effect ef = (Effect)effects.get(i);
				game.addEffect(ef);
			}//next i
			
		}catch(Exception e)
		{
			System.out.println("ERROR: CODE 10");
			System.out.println(e.getMessage().toString());
			System.out.println(e.getLocalizedMessage().toString());
		}
	}//buildMap
	
	public void update()
	{
		try
		{
			Unit mu;
			if(game.getMyUnit()==null)
			{
				mu = null;
			}else
			{
				mu = game.getMyUnit();
			}
			//game.getUnitList().clear();
			IntValue k = new IntValue(0);
			int num=0;
			String temp="";
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue()+1);
			}//loop
			num = Integer.parseInt(temp);
			Vector units = new Vector();
			while(num>0)
			{
				Unit u = getBoardUnit(k);
                if((mu!=null))
                {
                        if((mu.getOwner().equalsIgnoreCase(u.getOwner()))&&(mu.getMoved()))
                        {
                        	mu.setMaxHp(u.getMaxHp());
                        	mu.setHp(u.getHp());
                        	mu.setStealth(u.getStealth());
                        	mu.setPerception(u.getPerception());
                        	mu.setInitiative(u.getInitiative());
                        	u=mu;
                        }
                }
                u.setMoved(false);
				units.add(u);
				num=num-1;
			}//loop
			while(game.getUnitList().size()>0)
			{
				Unit un = (Unit)game.getUnitList().get(0);
				game.removeUnit(un);
			}//loop
			game.getUnitList().clear();
			for(int i=0;i<units.size();i++)
			{
				Unit un = (Unit)units.get(i);
				/*if(un.getTurn()==1)
				{
					game.setTurnUnit(un);
				}*/
				game.addUnit(un);
			}//next i
			
			//TERRAIN:
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			if(num>0)
			{
				k.setValue(k.getValue() + 1);
			}
			Vector terrain = new Vector();
			while(num>0)
			{
				Terrain t = getBoardTerrain(k);
				terrain.add(t);
				num=num-1;
			}//loop
			while(game.getTerrainList().size()>0)
			{
				Terrain te = (Terrain)game.getTerrainList().get(0);
				game.removeTerrain(te);
			}//loop
			game.getTerrainList().clear();
			for(int i=0;i<terrain.size();i++)
			{
				Terrain te = (Terrain)terrain.get(i);
				game.addTerrain(te);
			}//next i
			
			//MARKERS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			if(num>0)
			{
				k.setValue(k.getValue() + 1);
			}
			Vector markers = new Vector();
			while(num>0)
			{
				Marker m = getBoardMarker(k);
				markers.add(m);
				num=num-1;
			}//loop
			while(game.getMarkerList().size()>0)
			{
				Marker ma = (Marker)game.getMarkerList().get(0);
				game.removeMarker(ma);
			}//loop
			game.getMarkerList().clear();
			for(int i=0;i<markers.size();i++)
			{
				Marker ma = (Marker)markers.get(i);
				game.addMarker(ma);
			}//next i
			
			//OBJECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			if(num>0)
			{
				k.setValue(k.getValue() + 1);
			}
			Vector objects = new Vector();
			while(num>0)
			{
				Object o = getBoardObject(k);
				objects.add(o);
				num=num-1;
			}//loop
			while(game.getObjectList().size()>0)
			{
				Object ob = (Object)game.getObjectList().get(0);
				game.removeObject(ob);
			}//loop
			game.getObjectList().clear();
			for(int i=0;i<objects.size();i++)
			{
				Object ob = (Object)objects.get(i);
				game.addObject(ob);
			}//next i
			
			//EFFECTS
			temp="";
			while(mess.charAt(k.getValue())!= ',')
			{
				temp=temp+mess.charAt(k.getValue());
				k.setValue(k.getValue() + 1);
			}//loop
			num = Integer.parseInt(temp);
			if(num>0)
			{
				k.setValue(k.getValue() + 1);
			}
			Vector effects = new Vector();
			while(num>0)
			{
				Effect e = getBoardEffect(k);
				effects.add(e);
				num=num-1;
			}//loop
			while(game.getEffectList().size()>0)
			{
				Effect ef = (Effect)game.getEffectList().get(0);
				game.removeEffect(ef);
			}//loop
			game.getEffectList().clear();
			for(int i=0;i<effects.size();i++)
			{
				Effect ef = (Effect)effects.get(i);
				game.addEffect(ef);
			}//next i
			
		}catch(Exception e)
		{
			System.out.println("ERROR: CODE 5 : " + e.getMessage());
		}//catch
	}//update
	
	public String getTerrainRef()
	{
		String ref="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			ref = ref + mess.charAt(k);
			k=k+1;
		}//loop
		return ref;
	}//getTerrainRef()
	
	public String getTerrainName()
	{
		String tName="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			tName = tName + mess.charAt(k);
			k=k+1;
		}//loop
		return tName;
	}//getTerrainName()
	
	public String getMarkerRef()
	{
		String ref="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			ref = ref + mess.charAt(k);
			k=k+1;
		}//loop
		return ref;
	}//getTerrainRef()
	
	public String getMarkerName()
	{
		String mName="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			mName = mName + mess.charAt(k);
			k=k+1;
		}//loop
		return mName;
	}//getTerrainName()
	
	public int getTerrainSizeX()
	{
		String tSize="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k=k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			tSize = tSize + mess.charAt(k);
			k=k+1;
		}//loop
		try
		{
			return Integer.parseInt(tSize);
		}catch(Exception e)
		{
			return 1;
		}
	}//getTerrainSizeX()
	
	public int getTerrainSizeY()
	{
		try
		{
			String tSize="";
			int k = 0;
			while(mess.charAt(k)!=',')
			{
				k=k+1;
			}//loop
			k=k+1;
			while(mess.charAt(k)!=',')
			{
				k=k+1;
			}//loop
			k = k+1;
			while(mess.charAt(k)!=',')
			{
				k=k+1;
			}//loop
			k = k+1;
			while(mess.charAt(k)!=',')
			{
				tSize = tSize + mess.charAt(k);
				k=k+1;
			}//loop
			try
			{
				return Integer.parseInt(tSize);
			}catch(Exception e)
			{
				return 1;
			}
		}catch(Exception e2)
		{
			return 1;
		}
	}//getTerrainSizeY()
	
	public int getTerrainHeight()
	{
		String tHeight="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k=k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			tHeight = tHeight + mess.charAt(k);
			k=k+1;
		}//loop
		try
		{
			return Integer.parseInt(tHeight);
		}catch(Exception e)
		{
			return 0;
		}
	}//getTerrainHeight()
	
	public boolean getTerrainObstruction()
	{
		String tObs="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k=k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			tObs = tObs + mess.charAt(k);
			k=k+1;
		}//loop
		if(tObs.equals("1"))
		{
			return true;
		}else if(tObs.equals("0"))
		{
			return false;
		}else
		{
			return true;
		}
	}//getTerrainObstruction()
	
	public String getUnitRef()
	{
		String ref="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			ref = ref + mess.charAt(k);
			k=k+1;
		}//loop
		return ref;
	}//getUnitRef()
	public String getUnitName()
	{
		String name="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			name = name + mess.charAt(k);
			k=k+1;
		}//loop
		return name;
	}//getUnitName()
	public String getUnitOwner()
	{
		String owner="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			owner = owner + mess.charAt(k);
			k=k+1;
		}//loop
		return owner;
	}//getUnitOwner()
	public int getUnitSizeX()
	{
		String size="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			size = size + mess.charAt(k);
			k=k+1;
		}//loop
		try
		{
			if(Integer.parseInt(size)>0)
			{
				return Integer.parseInt(size);
			}else
			{
				return 1;
			}
		}catch(Exception e)
		{
			return 1;
		}
	}//getUnitSizeX()
	public int getUnitSizeY()
	{
		String size="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			size = size + mess.charAt(k);
			k=k+1;
		}//loop
		try
		{
			if(Integer.parseInt(size)>0)
			{
				return Integer.parseInt(size);
			}else
			{
				return 1;
			}
		}catch(Exception e)
		{
			return 1;
		}
	}//getUnitSizeY()
	public int getUnitMaxHp()
	{
		String maxHp="";
		int k = 0;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			k=k+1;
		}//loop
		k = k+1;
		while(mess.charAt(k)!=',')
		{
			maxHp = maxHp + mess.charAt(k);
			k=k+1;
		}//loop
		try
		{
			if(Integer.parseInt(maxHp)>0)
			{
				return Integer.parseInt(maxHp);
			}else
			{
				return 1;
			}
		}catch(Exception e)
		{
			return 1;
		}
	}//getUnitOwner()
}//class